import random

class Player:
    def __init__(self, name, hp, attack_distance, attack_damage):
        self.name = name
        self.hp = hp
        self.attack_distance = attack_distance
        self.attack_damage = attack_damage

    def attack(self, target):
        if abs(self.position - target.position) <= self.attack_distance:
            target.hp -= self.attack_damage

    def is_alive(self):
        return self.hp > 0

class Hunter(Player):
    def __init__(self):
        super().__init__("Hunter", 3, 2, 1)

    def attack(self, target):
        super().attack(target)
        print(f"{self.name} shoots an arrow at {target.name} and deals {self.attack_damage} damage.")

class Warrior(Player):
    def __init__(self):
        super().__init__("Warrior", 3, 1, 1)

    def attack(self, target):
        super().attack(target)
        print(f"{self.name} swings a sword at {target.name} and deals {self.attack_damage} damage.")

class Game:
    def __init__(self):
        self.players = []
        self.current_player = None
        self.other_player = None

    def start(self):
        print("Welcome to Hunter and Warrior game!")
        print("Please select your character:")
        print("1. Hunter")
        print("2. Warrior")
        player_choice = input()
        if player_choice == "1":
            self.players.append(Hunter())
            self.players.append(Warrior())
        else:
            self.players.append(Warrior())
            self.players.append(Hunter())
        self.current_player = self.players[0]
        self.other_player = self.players[1]
        self.play()

    def play(self):
        while True:
            print(f"{self.current_player.name}'s turn.")
            print(f"{self.current_player.name}: {self.current_player.hp} HP")
            print(f"{self.other_player.name}: {self.other_player.hp} HP")
            print("What do you want to do?")
            print("1. Attack")
            print("2. Pass")
            action_choice = input()
            if action_choice == "1":
                self.current_player.attack(self.other_player)
                if not self.other_player.is_alive():
                    print(f"{self.current_player.name} wins!")
                    break
            elif action_choice == "2":
                print(f"{self.current_player.name} passes.")
            else:
                print("Invalid choice.")
                continue
            self.current_player, self.other_player = self.other_player, self.current_player

game = Game()
game.start()
